/*
 * OpenParts
 * A dynamic-loading components framework for GWT
 * Copyright (C) 2011 Christophe Bouthier  [chris{AT}binary-gastronome{DOT}fr]
 *
 * This work is partially based on work I have done at INRIA (http://www.inria.fr) 
 * in the context of the Qualipso European Project (http://qualipso.org/),
 * The work done at INRIA is Copyright (C) 2006-2011 INRIA
 *
 * This work is distributed under the LGPL version 3
 *
 * This is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License version 3
 * as published by the Free Software Foundation. See the GNU
 * Lesser General Public License in LGPL.txt for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this software; if not, write to the Free
 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
 */
package fr.openparts.OpenParts.rebind;

import com.google.gwt.core.ext.typeinfo.JMethod;

/**
 * Manage data for event handlers callbacks.
 * 
 * @author Christophe Bouthier [chris{AT}binary-gastronome{DOT}fr]
 * @creation.date 27 December 2009
 */
public class OPBinderBuildingDataEventHandler {

    /**
     * The event handler callback.
     */
    protected final JMethod callback;

    /**
     * The events on which this callback is specialized. Can be empty, but cannot be null.
     */
    protected final String[] events;

    /**
     * Constructor. Takes the callback and if necessary the events on which this callback is specialized.
     * 
     * @param callback
     *            the event handler callback. Shouldn't be null.
     * @param events
     *            the events on which this callback is specialized. Can be empty, but shouldn't be null.
     */
    public OPBinderBuildingDataEventHandler(final JMethod callback, final String... events) {
        assert callback != null : "parameter callback shouldn't be null";
        assert events != null : "parameter events shouldn't be null";

        this.callback = callback;
        this.events = events;
    }

    /**
     * Return the event handler callback.
     * 
     * @return the event handler callback. Cannot be null.
     */
    public JMethod getCallback() {
        return callback;
    }

    /**
     * Return the events on which the callback is specialized.
     * 
     * @return the events on which the callback is specialized.  Can be empty, but cannot be null.
     */
    public String[] getEvents() {
        return events;
    }
}
